package com.kpijavatraining.module.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;

import com.kpijavatraining.module.Session;
import com.kpijavatraining.module.User;

public class Restore
{
	private InputStream inputStream;
	private ObjectInputStream objectInputStream;
	private Session session;
	private File file;

    public Session loadQuestions(User user) throws IOException, ClassNotFoundException
    {
    	file = new File(user.toString()+".ucl");
		inputStream = new FileInputStream(file);
		objectInputStream = new ObjectInputStream(inputStream);
		session = (Session)objectInputStream.readObject();
		objectInputStream.close();
		file.delete();
		return session;
    }
}
